#!/usr/bin/python

# BigData course project
# Generates n copies an ID matrix of arbitrary dimension

import sys

def gen_id_matrix(dim, n, fname):
    f = open(fname,"w")
    for k in xrange(0,n):
        for i in xrange(0,dim):
            cell = lambda j: str(1 if i==j else 0)
            f.write(" ".join(map(cell, xrange(dim))))
            f.write("\n")    
    f.close()
    return

# main
ec = 0
if len(sys.argv) != 4:
    print("\nUsage: %s <dim> <n> <fname>\n" % (sys.argv[0]))
    ec = 1
else:
    gen_id_matrix(int(sys.argv[1]), int(sys.argv[2]), sys.argv[3])
sys.exit(ec)
